<%@page import="com.qqtop10.manager.model.FooterInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>运营管理平台 - 顶十</title>
<%@include file="../include/imports.jsp"%>
<link rel="stylesheet"
	href="/assets/js/kindeditor/themes/default/default.css" />
<link rel="stylesheet"
	href="/assets/js/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8"
	src="/assets/js/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/assets/js/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8"
	src="/assets/js/kindeditor/plugins/code/prettify.js"></script>
<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]', {
			cssPath : '/assets/js/kindeditor/plugins/code/prettify.css',
			uploadJson : '/kindeditor/upload.do',
			allowFileManager : false,
			allowImageRemote : false,
			items : [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print',
					'template', 'code', 'cut', 'copy', 'paste', 'plainpaste',
					'wordpaste', '|', 'justifyleft', 'justifycenter',
					'justifyright', 'justifyfull', 'insertorderedlist',
					'insertunorderedlist', 'indent', 'outdent', 'subscript',
					'superscript', 'clearhtml', 'quickformat', 'selectall',
					'|', 'formatblock', '/', 'fontname', 'fontsize', '|',
					'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
					'strikethrough', 'lineheight', 'removeformat', '|',
					'image', 'insertfile', 'table', 'hr', 'emoticons',
					'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|',
					'about' ]
		});
		prettyPrint();
	});
</script>
</head>
<body>
	<div class="navbar" role="navigation">
		<%@include file="../include/top.jsp"%>
	</div>
	<div class="container-fluid content">
		<div class="row">
			<%@include file="../include/menu.jsp"%>
			<div class="main">
				<div class="row">
					<div class="col-md-12">
						<div class="panel panel-default">
						<div class="row toolbox">
							<input type="button" id="back" class="btn btn-sm btn-success" value="返回">
						</div>
							<div class="panel-heading">
								<h2>
									<i class="fa fa-align-left red"></i><strong>修改文章</strong>
								</h2>
							</div>
							<div class="panel-body " style="text-align: center;">
								<table style="margin: auto;">
									<tr>
										<td align="center">
											<select id="explain" style="display: inline-block; width:30%;" class="form-control">
												<option value="${info.type}">
													<%
														int type = ((FooterInfo) (request.getAttribute("info"))).getType();
														String[] typeNames = {"请选择文章类型", "网站说明", "返修/退换货", 
																"常见问题", "售后政策", "联系客服", 
																"招商合作", "隐私政策", "新手指南", 
																"卖家开店流程"};
														String typeName = typeNames[type];
													%>
													<%=typeName %>
												</option>
												<option value="1">网站说明</option>
												<option value="2">返修/退换货</option>
												<option value="3">常见问题</option>
												<option value="4">售后政策</option>
												<option value="5">联系客服</option>
												<option value="6">招商合作</option>
												<option value="7">隐私政策</option>
												<option value="8">新手指南</option>
												<option value="9">卖家开店流程</option>
										</select>
										&nbsp;&nbsp;&nbsp;&nbsp;
										<input class="form-control" style="display: inline-block; width:30%" id="title" type="text" name="title" value="${info.title }" />
										</td>
									</tr>
									<tr>
										<td align="center"><br></td>
									</tr>
									<tr>
										<td align="center">
											<form name="article" method="post" action="#">
												<textarea name="content" cols="100" rows="8"
													style="width: 700px; height: 500px; visibility: hidden;">
														${info.htmltext }
													</textarea>
												<br /> <input type="button" onclick="updateArticle()"
													value="提交内容" class="btn btn-sm btn-primary" />
											</form>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	
		$(function(){
			$("#back").click(function(){
				window.location.href = "/manager/footerInfo.do";
			});
		});
	
		function updateArticle() {
			var explain = $("#explain").val();
			var content = editor.html();
			var text = editor.text();
			
			var title = $("#title").val();
			if (explain == undefined || explain == 0) {
				return;
			}
			if (content.length <= 0) {
				return;
			}
			var id = ${info.id};
			$.ajax({
				url : "/manager/footer/updateInfo.do",
				data : {
					"id" : id,
					"type" : explain,
					"htmltext" : content,
					"text" : text,
					"title":title
				},
				type : "post",
				success : function(res) {
					layer.msg(res.msg);
				}
			});
		}
	</script>
</body>
</html>